package com.hlhj.carview.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.hlhj.carview.Iview.AdvDetailView
import com.hlhj.carview.bean.AdvDetailBean
import com.hlhj.carview.bean.MyBaseBean
import com.hlhj.carview.http.Apis
import com.hlhj.carview.http.CustomAction
import com.hlhj.carview.http.LoadingAction
import com.lzy.okgo.model.Response

/**
 * Created by Never Fear   on 2018\12\24 0024.
Never More....
 */
class AdvDetailModule :BaseModule {
    var lis:AdvDetailView?=null
    fun getDetail(aid:Int,c:Context){
        Apis?.getAdvDetail(aid)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<AdvDetailBean>>(c){
                                override fun httpSuccess(t: Response<AdvDetailBean>) {
                                    lis?.setDetail(t.body())
                                }
                            })
                }
    }
    fun choucheng(advertising_id:Int,advertising_name:String,c:Context){
        Apis?.choucheng(advertising_id,advertising_name)
                ?.let {
                    it.subscribe(object :CustomAction<Response<MyBaseBean>>(c){
                        override fun httpSuccess(t: Response<MyBaseBean>) {

                        }
                    })
                }
    }
}